#ifndef SERVER_H
#define SERVER_H

#include <QMainWindow>
#include <QTcpServer>
#include <QTcpSocket>
#include <QList>
#include <QListWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>

QT_BEGIN_NAMESPACE
namespace Ui {
class Server;
}
QT_END_NAMESPACE

class Server : public QMainWindow

{
    Q_OBJECT

public:
    Server(QWidget *parent = nullptr);
    ~Server();

private slots:
    void on_pushButton_clicked();
    void newConnection();
    void readyRead();
    void clientDisconnected();

    void on_Btn_Del_clicked();

    void on_Btn_Del_All_clicked();

private:
    Ui::Server *ui;
    QTcpServer *tcpServer;
    QList<QTcpSocket*> clients;
    QSqlDatabase db;

    void initDatabase();
    void saveToDatabase(const QString &plate, const QString &brand,
                        const QString &series, const QString &type,
                        const QString &color, const QString &enterTime,
                        const QString &leaveTime);
    void updateRecordList();

     QMap<QListWidgetItem*, int> itemIdMap;  // �������洢�б������¼ID��ӳ��
};

#endif // SERVER_H
